<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // toString()
    // valueOf()
    // hasOwnProperty()
    // propertyIsEnumerable()
    // isPrototypeOf()


    // toString()   将其他类型转化为字符串类型
    /* var num = 1;
    var str = "hello";
    var bool = true;
    var arr = [1, 2, 3];
    var obj = { a: 1, b: 2 }
    var p = new Promise(function () { })
    console.log(num.toString());
    console.log(str.toString());
    console.log(bool.toString());
    console.log(arr.toString());
    console.log(obj.toString());
    console.log(p.toString()); */

    /* var num = new Number(1);
    var str = new String("hello");
    var bool = new Boolean(true);
    var arr = [1, 2, 3];
    var obj = { a: 1, b: 2 }
    var p = new Promise(function () { });

    console.dir(num);
    console.dir(str);
    console.dir(bool);
    console.dir(arr);
    console.dir(obj);
    console.dir(p);

    // 访问自己构造函数原型对象上的toString => 将数据转化为对应的字符串格式
    console.log(num.toString()); // Number.prototype.toString
    console.log(str.toString());
    console.log(bool.toString());
    console.log(arr.toString());

    // 访问Object.prototype.toString  => 返回数据类型 以及对应的构造函数
    console.log(obj.toString());  // Object.prototype.toString   '[object Object]'
    console.log(p.toString());  // Object.prototype.toString    '[object Promise]'
 */

    // valueOf()  返回实例化对象的值本身 (隐式转换时可能也会触发此方法)

    // var num = new Number(1);
    // var str = new String("hello");
    // var bool = new Boolean(true);
    // var arr = [1, 2, 3];
    // var obj = { a: 1, b: 2 }
    // var p = new Promise(function () { });
    // console.log(num.valueOf());
    // console.log(str.valueOf());
    // console.log(bool.valueOf());
    // console.log(arr.valueOf());
    // console.log(obj.valueOf());
    // console.log(p.valueOf());


    // hasOwnProperty()   






    
    // propertyIsEnumerable()
    // isPrototypeOf()



</script>

</html>